package es.udc.pfc.davidparedes.web.pages.user;

import java.util.List;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;

import es.udc.pfc.davidparedes.model.receptionist.Receptionist;
import es.udc.pfc.davidparedes.model.store.Store;
import es.udc.pfc.davidparedes.model.storeservice.StoreService;
import es.udc.pfc.davidparedes.model.universemanager.UniverseManager;
import es.udc.pfc.davidparedes.model.userprofile.UserProfile;
import es.udc.pfc.davidparedes.model.userservice.UserService;
import es.udc.pfc.davidparedes.model.util.InstanceNotFoundException;
import es.udc.pfc.davidparedes.web.services.AuthenticationPolicy;
import es.udc.pfc.davidparedes.web.services.AuthenticationPolicyType;
import es.udc.pfc.davidparedes.web.util.UserSession;

@AuthenticationPolicy(AuthenticationPolicyType.DIRECTOR)
public class ManageUM {
	
	@Property
	private List<UniverseManager> managers;
	
	@Property
	private List<Receptionist> receptionists;
	
	@Property
	private Receptionist receptionist;
	
	@Property
	private UniverseManager manager;
    
    @SessionState(create=false)
    private UserSession userSession;
    
    @Inject
    private UserService userService;
    
    @Inject
    private StoreService storeService;
    
    void onActivate() throws InstanceNotFoundException {
		
    	UserProfile userProfile = userService.findUserProfile(userSession.getUserProfileId());
    	Store store = userProfile.getStore();
    	managers = storeService.getStoreManagers(store.getStoreId());
    	receptionists = storeService.getStoreReceptionists(store.getStoreId());
    		
    }

}
